import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lib_database/lib_database.dart';
import 'package:lib_util/utils/utils.dart';

class TokenMarketText extends StatelessWidget {
  final Token token;

  const TokenMarketText({super.key, required this.token});

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Text(
          '${null == token.priceusd || token.priceusd!.isEmpty ? '\$0.00' : '\$${Utils.formatStringBalance(token.priceusd!, fractionDigits: 2)}'}',
          style: TextStyle(
              fontSize: 12.sp,
              fontWeight: FontWeight.normal,
              height: (14 / 12).w,
              fontFamily: '_DIN',
              color: Color.fromRGBO(190, 189, 202, 1)),
        ),
        SizedBox(
          width: 5.w,
        ),
        Text(
          '${(token.change24h == null || token.change24h == '') ? '0.00' : '${Utils.formatStringBalance(token.change24h!, fractionDigits: 2)}'}%',
          style: TextStyle(
              fontSize: 12.sp,
              height: (14 / 12).w,
              fontWeight: FontWeight.normal,
              fontFamily: '_DIN',
              color: (token.change24h == '' || token.change24h == null)
                  ? Color.fromRGBO(58, 177, 151, 1)
                  : double.parse(token.change24h ?? '0') < 0
                  ? Color.fromRGBO(224, 66, 28, 1)
                  : Color.fromRGBO(58, 177, 151, 1)),
        )
      ],
    );
  }
}
